import {
	http,
	api
} from '@/config/common.js' // 全局挂载引入，配置相关在该common.js文件里修改

export default {
	/**
	 * @param {Object} url 接口地址
	 * @param {Object} method 请求方式
	 * @param {Object} data 数据
	 * @param {Object} loadingMsg 加载提示框提示信息
	 */
	http(url, method, data, loadingMsg, authorization) {
		if (method == 'POST') {
			return api.post(url, data, {
				custom: {
					loadingMsg: loadingMsg
				}
			});
		} else if (method == 'GET') {
			return api.get(url);
		}else if (method == 'DELETE') {
			return api.delete(url);
		} else if (method == 'PUT') {
			return api.put(url, data, {
				custom: {
					loadingMsg: loadingMsg
				}
			});
		}
	},

	loginToGetList(authorization, callback) {
		uni.request({
			url: 'https://viptest.babybear.cn/shop/store-api/list',
			header: {
				'authorization': authorization
			},
			success: (res) => {
				callback(res);
			},
			fail: (res) => {

			},
		});
	}
}
